package com.guchenbo.example.thread.singleton;

/**
 * @Author guchenbo
 * @Date 2019/7/5.
 */
public class DoubleCheckSingletonFactory {

    private static volatile Singleton instance;

    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (DoubleCheckSingletonFactory.class) {
                if (instance == null) {
                    System.out.println(Thread.currentThread().getName() + " create instance");
                    instance = new Singleton("java");
                }
            }
        }
        return instance;
    }
}
